home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / include / php / Zend / zend_llist.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-18  |  3.7 KB  |  78 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | Zend Engine                                                          |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 0.92 of the Zend license,     |
  8.    | that is bundled with this package in the file LICENSE, and is        | 
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.zend.com/license/0_92.txt.                                |
  11.    | If you did not receive a copy of the Zend license and are unable to  |
  12.    | obtain it through the world-wide-web, please send a note to          |
  13.    | license@zend.com so we can mail you a copy immediately.              |
  14.    +----------------------------------------------------------------------+
  15.    | Authors: Andi Gutmans <andi@zend.com>                                |
  16.    |          Zeev Suraski <zeev@zend.com>                                |
  17.    +----------------------------------------------------------------------+
  18. */
  19.  
  20.  
  21. #ifndef ZEND_LLIST_H
  22. #define ZEND_LLIST_H
  23.  
  24. #include <stdlib.h>
  25.  
  26. typedef struct _zend_llist_element {
  27.     struct _zend_llist_element *next;
  28.     struct _zend_llist_element *prev;
  29.     char data[1]; /* Needs to always be last in the struct */
  30. } zend_llist_element;
  31.  
  32. typedef struct _zend_llist {
  33.     zend_llist_element *head;
  34.     zend_llist_element *tail;
  35.     size_t size;
  36.     void (*dtor)(void *data);
  37.     unsigned char persistent;
  38.     zend_llist_element *traverse_ptr;
  39. } zend_llist;
  40.  
  41. typedef int (*llist_compare_func_t)(const zend_llist_element *, const zend_llist_element *);
  42. typedef void(*llist_apply_with_arg_func_t)(void *data, void *arg);
  43. typedef void(*llist_apply_with_args_func_t)(void *data, int num_args, va_list args);
  44. typedef void (*llist_apply_func_t)(void *);
  45.  
  46. typedef zend_llist_element* zend_llist_position;
  47.  
  48. BEGIN_EXTERN_C()
  49. ZEND_API void zend_llist_init(zend_llist *l, size_t size, void (*dtor)(void *data), unsigned char persistent);
  50. ZEND_API void zend_llist_add_element(zend_llist *l, void *element);
  51. ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element);
  52. ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2));
  53. ZEND_API void zend_llist_destroy(zend_llist *l);
  54. ZEND_API void zend_llist_clean(zend_llist *l);
  55. ZEND_API void zend_llist_remove_tail(zend_llist *l);
  56. ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
  57. ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t);
  58. ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
  59. ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t, void *arg);
  60. ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int num_args, ...);
  61. ZEND_API int zend_llist_count(zend_llist *l);
  62. ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func);
  63.  
  64. /* traversal */
  65. ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos);
  66. ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos);
  67. ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos);
  68. ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos);
  69.  
  70. #define zend_llist_get_first(l) zend_llist_get_first_ex(l, NULL)
  71. #define zend_llist_get_last(l) zend_llist_get_last_ex(l, NULL)
  72. #define zend_llist_get_next(l) zend_llist_get_next_ex(l, NULL)
  73. #define zend_llist_get_prev(l) zend_llist_get_prev_ex(l, NULL)
  74.  
  75. END_EXTERN_C()
  76.  
  77. #endif /* ZEND_LLIST_H */
  78.